Package com.seclore.fs.ws.client
Class WSClient
java.lang.Object
com.seclore.fs.ws.client.WSClient
This class provides methods to deal with the file operations like
- protecting a file
- unprotecting a file
- validating that the file is protected
- get the protected file header
- generate the file details for protect
-
Method Summary
Modifier and TypeMethodDescriptioncom.seclore.fs.ws.client.mail.utilities.SMailDetailscreateSMail(IMailInput pMailInput, String pFolderPath) This method creates SMail File in provided folder path using Mail Input.getCustomAttributesFromHTMLFile(String pFilePath) This method returns the Custom Attributes from HTML file.getFileDetailsXML(String pFile) This method returns the file details XML that can be used to call the protect API to Policy Server.getFileDetailsXML(String pFile, String pDisplayFile) This method returns the file details XML that can be used to call the protect API to Policy Server.getFileHeader(com.seclore.io.SeekableStream pInputStream) getFileHeader(String pProtectedFile) This method reads the given file and return the header if it is protected else throws exception.This method reads the given file and return the File Id if it is protected else throws exception.getHtmlCustomMetadata(String pFilePath) This method returns the Custom HTML MetaData from HTML file.getHtmlWrappedFileHeader(com.seclore.io.SeekableStream pInputStream) getHtmlWrappedFileHeader(String pHtmlWrappedFile) This method reads the given html wrapped file and returns the header if it is protected else throws exception.getHtmlWrappedFileId(String pHtmlWrappedFile) This method reads the given html wrapped file and returns the File Id if it is protected else throws exception.getLocaleFromHTMLFile(String pFilePath) This method returns the Locale of the HTML file.getPsIdFromFile(String pProtectedFile) com.seclore.fs.ws.client.wrapper.html.versions.InternalHtmlWrapperVersionsThis method returns HTML wrapper buffer and form data versions which is supported by wsclient.static StringThis method returns the version information.booleanisAdvancedProtectionSupportedFile(String pFilePath) This method returns whether a file is of advance protection FileSecure supported extension or not.booleanisBasicProtectionSupportedFile(String filePath) This method returns whether a file is of basic protection FileSecure supported extension or not.booleanisHtmlWrappedFile(byte[] pFileData) booleanisHtmlWrappedFile(String pFilePath) This method determines whether the given file is html wrapped or not.booleanisHtmlWrapSupported(String pFilePath) This method returns whether a file is supported for HTMl wrap or not.booleanisProtectedFile(byte[] pFileData) This method returns whether a passed bytes are of FileSecure protected file or not.booleanisProtectedFile(String pFilePath) This method returns whether a file is FileSecure protected or not.booleanisSupportedFile(String pFilePath) This method returns whether a file is of FileSecure supported extension or not.static WSClientnewInstance(WSClientConfig pWSClientConfig) Calls the private constructor of WSClient.voidThis method protects the requested File.protectAndGetFileName(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML) This method protects the requested File.protectAndGetFileName(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) com.seclore.fs.helper.core.ProtectedFileprotectAndGetProtectedFile(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) This method protects the requested File.voidsetExternalHtmlWrapperVersions(Node pHtmlWrapperVersion) Set HTML wrapper buffer and form data versions which is received in PS ping response.com.seclore.fs.helper.core.UnprotectedFileunprotect(String pProtectedFile, String pUnProtectResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) This method unprotect the requested file, if it is already protected, else will throw error.com.seclore.fs.helper.core.UnwrapOutputDetailsThis method will unwrap the protected wrapped file at pSourceFilePath and return the absolute path of unwrapped file.wrap(com.seclore.fs.helper.core.WrapperInputDetails pWrapperDetailsBean) This method wrap (convert) protected file into HTML file and return absolute file location of wrapped file.
-
Method Details
-
newInstance
Calls the private constructor of WSClient.- Parameters:
pWSClientConfig- - WSClient Configuration- Returns:
- WSClient object
- Throws:
WSClientException
-
getFileHeader
This method reads the given file and return the header if it is protected else throws exception.- Parameters:
pProtectedFile- The name of the file along with the complete path of the file whose header is requested.- Returns:
- The protected file header.
- Throws:
WSClientException- The WSClientException thrown by the method.IOException- The IOException thrown by the method.
-
getFileHeader
- Throws:
WSClientException
-
getHtmlWrappedFileHeader
This method reads the given html wrapped file and returns the header if it is protected else throws exception.- Parameters:
pHtmlWrappedFile- The name of the file along with the complete path of the file whose header is requested.- Returns:
- The protected file header.
- Throws:
WSClientException- The WSClientException thrown by the method.IOException- The IOException thrown by the method.
-
getHtmlWrappedFileHeader
public String getHtmlWrappedFileHeader(com.seclore.io.SeekableStream pInputStream) throws WSClientException - Throws:
WSClientException
-
getFileId
This method reads the given file and return the File Id if it is protected else throws exception.- Parameters:
pProtectedFile- The name of the file along with the complete path of the file whose header is requested.- Returns:
- The protected file Id.
- Throws:
WSClientException- The WSClientException thrown by the method.IOException- The IOException thrown by the method.
-
getHtmlWrappedFileId
This method reads the given html wrapped file and returns the File Id if it is protected else throws exception.- Parameters:
pHtmlWrappedFile- The name of the file along with the complete path of the file whose header is requested.- Returns:
- The seclore file Id.
- Throws:
WSClientException- The WSClientException thrown by the method.IOException- The IOException thrown by the method.
-
unprotect
public com.seclore.fs.helper.core.UnprotectedFile unprotect(String pProtectedFile, String pUnProtectResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) throws WSClientException This method unprotect the requested file, if it is already protected, else will throw error.- Parameters:
pProtectedFile- Name along with the complete path of protected file.pUnProtectResponseXML- Unprotect API response returned by the Policy Server.pIsSecureMessage- Is the Response XML is in secure communication format.pRequestKey- Request Key to decrypt the Response XML if the xml is in secure communication format.pCryptoHandler- CryptoHandler to decrypt the Response XML if the xml is in secure communication format.- Throws:
WSClientException- The WSClientException thrown by the method in case any IO error occurs.
-
getFileDetailsXML
This method returns the file details XML that can be used to call the protect API to Policy Server.- Parameters:
pFile- The name of the file along with the complete path of the file to be protected. File should exist on the disk.pDisplayFile- Display name of the file.
File need not exist on the disk. This value will be used for protect activity.
This value should contain the complete file path. if only filename is passed, then we use the same value for path and file name.- Returns:
- The File details XML
- Throws:
WSClientException- The WSClientException thrown by the method.IOException- The IOException thrown by the method.
-
getFileDetailsXML
This method returns the file details XML that can be used to call the protect API to Policy Server.- Parameters:
pFile- The name of the file along with the complete path of the file to be protected.- Returns:
- The File details XML
- Throws:
WSClientException- The WSClientException thrown by the method.IOException- The IOException thrown by the method.
-
getVersion
This method returns the version information. -
protect
public void protect(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML) throws WSClientException This method protects the requested File.- Parameters:
pOriginalFileName- Name along with the complete path of the file to be protected.pFileInfoXML- XML which is used to call the protect API to Policy Server.pProtectionResponseXML- Response XML of the protect request API from the Policy Server.- Throws:
WSClientException- The WSClientException thrown by the method in case of any IO error.
-
createSMail
public com.seclore.fs.ws.client.mail.utilities.SMailDetails createSMail(IMailInput pMailInput, String pFolderPath) throws WSClientException This method creates SMail File in provided folder path using Mail Input.- Parameters:
pMailInput- MailInput class contains all the information required for creating smail filepFolderPath- path in which SMail file is to be created- Returns:
- Throws:
WSClientExceptionIOException
-
protectAndGetFileName
public String protectAndGetFileName(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML) throws WSClientException This method protects the requested File.- Parameters:
pOriginalFileName- Name along with the complete path of the file to be protected.pFileInfoXML- XML which is used to call the protect API to Policy Server.pProtectionResponseXML- Response XML of the protect request API from the Policy Server.- Returns:
- Returns the Unique File Identifier.
- Throws:
WSClientException- The WSClientException thrown by the method in case of any IO error.
-
protectAndGetFileName
public String protectAndGetFileName(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) throws WSClientException - Throws:
WSClientException
-
protectAndGetProtectedFile
public com.seclore.fs.helper.core.ProtectedFile protectAndGetProtectedFile(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) throws WSClientException This method protects the requested File.- Parameters:
pOriginalFileName- Name along with the complete path of the file to be protected.pFileInfoXML- XML which is used to call the protect API to Policy Server.pProtectionResponseXML- Response XML of the protect request API from the Policy Server.pIsSecureMessage- Is the Response XML is in secure communication format.pRequestKey- Request Key to decrypt the Response XML if the xml is in secure communication format.pCryptoHandler- CryptoHandler to decrypt the Response XML if the xml is in secure communication format.- Returns:
- Returns the Unique File Identifier.
- Throws:
WSClientException- The WSClientException thrown by the method in case of any IO error.
-
isProtectedFile
This method returns whether a file is FileSecure protected or not. It takes file path as input parameter.- Parameters:
pFilePath- This string contains the path of the file which is to be checked for FileSecure protection.- Returns:
- true, if the file is protected else false.
- Throws:
WSClientException
-
isProtectedFile
This method returns whether a passed bytes are of FileSecure protected file or not.- Parameters:
pFileData- This should be bytes of the file which is to be checked for FileSecure protection. Only first 1 MB of the file data needs to be passed here. If the file size is less than 1 MB then the entire file data should be passed.- Returns:
- true, if the bytes are of FileSecure protected file else false.
- Throws:
WSClientException
-
isAdvancedProtectionSupportedFile
This method returns whether a file is of advance protection FileSecure supported extension or not.- Parameters:
pFilePath-- Returns:
- Throws:
WSClientException
-
isSupportedFile
This method returns whether a file is of FileSecure supported extension or not.- Parameters:
pFilePath- It contains the path of the file for which we have to determine if it is of FileSecure supported extension or not. This may be just the name of the file also.- Returns:
- true, if the file is FileSecure supported extension.
- Throws:
WSClientException
-
isBasicProtectionSupportedFile
This method returns whether a file is of basic protection FileSecure supported extension or not.- Parameters:
filePath- - It contains the path of the file for which we have to determine if it is of FileSecure supported extension or not. This may be just the name of the file also.- Returns:
- true, if the file is FileSecure supported extension.
- Throws:
WSClientException
-
wrap
public String wrap(com.seclore.fs.helper.core.WrapperInputDetails pWrapperDetailsBean) throws WSClientException This method wrap (convert) protected file into HTML file and return absolute file location of wrapped file. Wrapped HTML file will be created in same directory of pProtectedFilePath and name of the HTML file will be same as protected filename followed by ".html" suffix. Example: If the protected file is 'D:/SampleFile.pdf' then wrapped HTML file will be 'D:/SampleFile.pdf.html'.
This method also takes custom data to be written in wrapped file, also encode (escape) the data for HTML before writing into file so caller should just pass the data.
Note: This method does not delete the protected file after wrapping. Caller should delete both protected file and HTML wrapped file after uses.- Parameters:
pWrapperDetailsBean- This bean is a wrapper. The data from this bean will be used for wrapping.- Returns:
- Absolute path of target HTML wrapped file.
- Throws:
WSClientException- - The WSClientException thrown by the method in case of any IO error.
-
unwrap
public com.seclore.fs.helper.core.UnwrapOutputDetails unwrap(String pHtmlWrappedFilePath) throws WSClientException This method will unwrap the protected wrapped file at pSourceFilePath and return the absolute path of unwrapped file. Unwrapped file would be created in same directory of the pSourceFilePath.
Unwrapped file name will be created with same name as source file name without '.html' extension. If original extension is not present in source file name then the original extension will be appended.
Example:
1. If wrapped file name is "SampleFile.pdf.html" and original file is "SampleFile.docx", then unwrapped file name would be SampleFile.pdf.docx
2. If wrapped file name is "SampleFile.pdf.html" and original file is "SampleFile.pdf", then unwrapped file name would be SampleFile.pdf
Note: This method does not delete the html file after un-wrapping. Caller should delete both protected file and HTML wrapped file after uses. NOTE : There should not be any file in the directory of pHtmlWrappedFilePath with SAME NAME irrespective of the extension.- Parameters:
pHtmlWrappedFilePath- Absolute path of html file to be un-wrapped.- Returns:
- Absolute path of unwrapped protected file.
- Throws:
WSClientException- - The WSClientException thrown by the method in case of any IO error.
-
isHtmlWrapSupported
This method returns whether a file is supported for HTMl wrap or not. It takes file path as input parameter.- Parameters:
pFilePath- This string contains the path of the file which is to be checked for HTML wrap.- Returns:
- true, if the file is supported for HTMl wrap.
- Throws:
WSClientException
-
isHtmlWrappedFile
This method determines whether the given file is html wrapped or not.- Parameters:
pFilePath- : Absolute path of the file which is to be checked.- Returns:
- True if the file is html wrapped or it returns false.
- Throws:
WSClientException
-
isHtmlWrappedFile
- Throws:
WSClientException
-
getCustomAttributesFromHTMLFile
This method returns the Custom Attributes from HTML file.- Parameters:
pFilePath- : Absolute path of the file which is to be checked.- Returns:
- Custom Attributes as String. null if no custom attribute is present in the file.
- Throws:
WSClientException
-
getHtmlCustomMetadata
This method returns the Custom HTML MetaData from HTML file.- Parameters:
pFilePath- : Absolute path of the file.- Returns:
- Custom HTML MetaData as String. null if no custom HTML MetaData is present in the file.
- Throws:
WSClientException
-
getLocaleFromHTMLFile
This method returns the Locale of the HTML file.- Parameters:
pFilePath- : Absolute path of the file which is to be checked.- Returns:
- Locale as String. null if no locale attribute is present in the file.
- Throws:
WSClientException
-
getPsIdFromFile
- Throws:
WSClientException
-
getSupportedHTMLWrapperVersions
public com.seclore.fs.ws.client.wrapper.html.versions.InternalHtmlWrapperVersions getSupportedHTMLWrapperVersions() throws WSClientExceptionThis method returns HTML wrapper buffer and form data versions which is supported by wsclient.- Returns:
- InternalHtmlWrapperVersions
- Throws:
WSClientException
-
setExternalHtmlWrapperVersions
Set HTML wrapper buffer and form data versions which is received in PS ping response.- Parameters:
pHtmlWrapperVersion-- Throws:
WSClientException
-